function PlotOrbitMultiple(R) % R coming in as a cell of states.

    Re = 6378.136;
    %[km]Mean equatorial radius of the Earth.
    R_all = [];
    for ii = 1:length(R)
        R{ii} = R{ii} / Re;
        %[Earth radii]Converts all positions from kilometers to Earth radii.
        
        R_all = [R_all , R{ii}];
        
    end
    r = zeros(1,length(R_all));
    for ii = 1:length(R_all)
       
        r(ii) = norm(R_all(:,ii)); 
        
    end
    
    n = size(R,2);
    %[]Number of points that will be plotted.
    
    Extent = 1.5*max(r);
    %[]Axes extents.
    
    [xe,ye,ze] = ellipsoid(0,0,0,1,1,1,50);
    %[Earth radii]Determines the coordinates of the Earth.
    
    Earth = imread('Earth.bmp');
    %[]Loads the image of the Earth.
    
    ScreenSize = get(0,'ScreenSize');
    %[]Determines the location and dimensions of the current monitor.
    
    Window = figure( ...
        'Color','w', ...
        'Name','ORBIT IN THREE DIMENSTIONS', ...
        'NumberTitle','Off', ...
        'OuterPosition',ScreenSize);
    %[]Opens a new window and adjusts its properties.
    
    Axes = axes( ...
        'CameraPosition',Extent*[1.2,1.2,1.2], ...
        'CameraTarget',[0,0,0], ...
        'FontName','Arial', ...
        'FontSize',8, ...
        'FontWeight','Bold', ...
        'Parent',Window, ...
        'PlotBoxAspectRatio',[1,1,1], ...
        'NextPlot','Add', ...
        'XGrid','On', ...
        'YGrid','On', ...
        'ZGrid','On', ...
        'XLim',Extent * [-1,1], ...
        'YLim',Extent * [-1,1], ...
        'ZLim',Extent * [-1,1], ...
        'XTick',Extent * (-1:0.2:1), ...
        'YTick',Extent * (-1:0.2:1), ...
        'ZTick',Extent * (-1:0.2:1),...
        'Color','w');
    %[]Adds an axes to the specified window and adjusts its properties.
    
    surface(xe,ye,-ze, ...
        'EdgeColor','flat', ...
        'FaceColor','TextureMap', ...
        'Parent',Axes);
    %[]Adds a plot to the specified axes and adjusts its properties.
    
    for ii = 1:length(R)-1
        plot3(R{ii}(1,:),R{ii}(2,:),R{ii}(3,:), ...
            'Color','k', ...
            'LineStyle','-', ...
            'Marker','o', ...
            'MarkerSize',1, ...
            'MarkerEdgeColor','k',...
            'MarkerFaceColor','k',...
            'Parent',Axes);
        %[]Adds a plot to the specified axes and adjusts its properties.
        plot3(R{ii}(1,:),R{ii}(2,:),-Extent*ones(1,length(R{ii})),'-','color',[0.3 0.3 0.3]);
        plot3(-Extent*ones(1,length(R{ii})),R{ii}(2,:),R{ii}(3,:),'-','color',[0.3 0.3 0.3]);
        plot3(R{ii}(1,:),-Extent*ones(1,length(R{ii})),R{ii}(3,:),'-','color',[0.3 0.3 0.3]);
    end

    for ii = length(R)
        plot3(R{ii}(1,:),R{ii}(2,:),R{ii}(3,:), ...
            'Color','r', ...
            'LineStyle','-', ...
            'Marker','o', ...
            'MarkerSize',1, ...
            'MarkerEdgeColor','r',...
            'MarkerFaceColor','r',...
            'Parent',Axes);
        %[]Adds a plot to the specified axes and adjusts its properties.
        plot3(R{ii}(1,:),R{ii}(2,:),-Extent*ones(1,length(R{ii})),'-','color',[0.3 0.3 0.3]);
        plot3(-Extent*ones(1,length(R{ii})),R{ii}(2,:),R{ii}(3,:),'-','color',[0.3 0.3 0.3]);
        plot3(R{ii}(1,:),-Extent*ones(1,length(R{ii})),R{ii}(3,:),'-','color',[0.3 0.3 0.3]);
    end
    plot3([0,Extent],[0,0],[0,0], ...
        'Color','r', ...
        'Linestyle','-', ...
        'LineWidth',3, ...
        'Marker','None', ...
        'Parent',Axes);
    %[]Adds a plot to the specified axes and adjusts its properties.
    
    plot3([0,0],[0,Extent],[0,0], ...
        'Color','r', ...
        'Linestyle','-', ...
        'LineWidth',3, ...
        'Marker','None', ...
        'Parent',Axes);
    %[]Adds a plot to the specified axes and adjusts its properties.
    
    plot3([0,0],[0,0],[0,Extent], ...
        'Color','r', ...
        'Linestyle','-', ...
        'LineWidth',3, ...
        'Marker','None', ...
        'Parent',Axes);
    %[]Adds a plot to the specified axes and adjusts its properties.
    
    xlabel( ...
        'Earth Radii', ...
        'FontSize',16, ...
        'Parent',Axes);
    %[]Adds a label to the specified axis.
    
    ylabel( ...
        'Earth Radii', ...
        'FontSize',16, ...
        'Parent',Axes);
    %[]Adds a label to the specified axis.
    
    zlabel( ...
        'Earth Radii', ...
        'FontSize',16, ...
        'Parent',Axes);
    %[]Adds a label to the specified axis.
    
    text( ...
        'BackGroundColor','w', ...
        'Color','r', ...
        'FontName','Arial', ...
        'FontSize',12, ...
        'FontWeight','Bold', ...
        'HorizontalAlignment','Center', ...
        'LineStyle','None', ...
        'Parent',Axes, ...
        'Position',[Extent,0,0], ...
        'String','X', ...
        'VerticalAlignment','Middle');
    %[]Adds a text box to the specified axes and adjusts its properties.
    
    text( ...
        'BackGroundColor','w', ...
        'Color','r', ...
        'FontName','Arial', ...
        'FontSize',12, ...
        'FontWeight','Bold', ...
        'HorizontalAlignment','Center', ...
        'LineStyle','None', ...
        'Parent',Axes, ...
        'Position',[0,Extent,0], ...
        'String','Y', ...
        'VerticalAlignment','Middle');
    %[]Adds a text box to the specified axes and adjusts its properties.
    
    text( ...
        'BackGroundColor','w', ...
        'Color','r', ...
        'FontName','Arial', ...
        'FontSize',12, ...
        'FontWeight','Bold', ...
        'HorizontalAlignment','Center', ...
        'LineStyle','None', ...
        'Parent',Axes, ...
        'Position',[0,0,Extent], ...
        'String','Z', ...
        'VerticalAlignment','Middle');
    %[]Adds a text box to the specified axes and adjusts its properties.
    
end
%===================================================================================================